define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		function get_data_assistenteList(result) {
			if(false) {
				result = '{"success":true,"msg":"","result":{"member":[{"member_id":"001","member_name":"Mary","part_id":"001","part_name":"售前客服"},{"member_id":"002","member_name":"Jane","part_id":"001","part_name":"售前客服"},{"member_id":"003","member_name":"Jane","part_id":"001","part_name":"售前客服"},{"member_id":"004","member_name":"Jane","part_id":"001","part_name":"售前客服"},{"member_id":"005","member_name":"Jane","part_id":"001","part_name":"售前客服"},{"member_id":"006","member_name":"Jane","part_id":"001","part_name":"售前客服"},{"member_id":"007","member_name":"Jane","part_id":"001","part_name":"售前客服"},{"member_id":"008","member_name":"Jane","part_id":"001","part_name":"售前客服"}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//删除
		function get_data_del(result) {
            if(false) {
                result = '{"success":true,"msg":"","result":"","session":"7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            } else {
                return result;
            }
        }
		function get_data_partList(result) {
			if(false) {
				result = '{"success": false,"msg": "","result": {"role": ['+
						'{"id": "001","name": "售前客服"},'+
						'{"id": "002","name": "售后客服"}]},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//编辑
		function get_data_assistenteEdit(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"member_id": "001"},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
			//我的店员一览
            assistente_list: function(nPage,callback,calldone) {
                Http.post({
                    method: 'member.assistente.getlist',
                    pagelimit:10,
                    nPage:nPage
                }, function(result) {
                    //函数回调
                    if(callback)
                        callback(get_data_assistenteList(result));

                }, function(e) {

                }, function() {
                    if(calldone)
                        calldone();
                });
            },
			part_delete: function(id,callback) {
				//post请求
				Http.post({
					method: 'member.assistente.delete',
					member_id:id,
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_del(result));
				}, function(e) {

				}, function() {

				});

			},
			//我的店员角色一览
			part_list: function(nPage,pagelimit,callback,calldone) {
				//post请求
				Http.post({
					method: 'member.assistente.partlist',
					nPage:nPage,
					pagelimit: pagelimit,
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_partList(result).result);

				}, function(e) {

				}, function() {
				    if(calldone)
                    	calldone();
				});

			},
			rights_delete: function(id,callback) {
				//post请求
				Http.post({
					method: 'member.assistente.partdelete',
					id: id
				}, function(result) {
					//函数回调
					if(callback)
						callback(result);
				}, function(e) {

				}, function() {

				});

			},					//修改
			modify: function(member_id, part_id, callback) {
				var params = new Object();
				params.member_id = member_id;
				params.part_id = part_id;
				params = JSON.stringify(params);
				Http.post({
					method: 'member.assistente.edit',
					updateParams: params
				}, function(result) {
					//函数回调
					if(callback)
						callback(get_data_assistenteEdit(result));
				}, function(e) {

				}, function() {

				});
			},

		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Employeemanager", factory);
});